/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 黎鹤舞
 * Date: 2023-11-17
 * Time: 20:24
 */
class Person {
    private String name = "张三";
    int age = 18;

    //用来传递private修饰的name的值
    public String getName() {
        return name;
    }

    //用来修改private修饰的name的值
    public void setName(String name) {
        this.name = name;
    }
}

public class Test {


    //private关键字测试
    public static void main(String[] args) {

        Person person = new Person();

        System.out.println("修改之前:" + person.getName());
        person.setName("李四");
        System.out.println("修改之后：" + person.getName());
    }
}